#include "StdAfx.h"
#include "Texture.h"

VAMPIRE_NAMESPACE_BEGIN

D3DRESOURCETYPE Texture::getTextureType() const
{
	return mpData->GetType();
}

void Texture::generateMipSubLevels()
{
	mpData->GenerateMipSubLevels();
}

BOOL Texture::createFromFile( const TString& name )
{	
	HRESULT hr = D3DXCreateTextureFromFile(gpDevice, name.c_str(), (LPDIRECT3DTEXTURE9*)(&mpData));
	if (FAILED(hr))
	{
		return FALSE;
	}
	return TRUE;
}

BOOL Texture::createAsRenderTarget( UINT width, UINT height, D3DFORMAT format )
{
	HRESULT hr = gpDevice->CreateTexture(width, height, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, (LPDIRECT3DTEXTURE9*)(&mpData), NULL);
	if (FAILED(hr))
	{
		return FALSE;
	}
	return TRUE;
}

BOOL Texture::createCubeTextureFromFile( const TString& name )
{
	D3DXCreateCubeTextureFromFile(gpDevice, name.c_str(), (LPDIRECT3DCUBETEXTURE9*)(&mpData));

	return TRUE;
}

VAMPIRE_NAMESPACE_END